<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang='en'>
<head>
	<meta charset='utf-8' />
	<title>杰购电子</title>
	<meta content='' name='description' />
	<meta content='' name='author' />
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<!-- Bootstrap -->
	<link href="__PUBLIC__/css/bootstrap.min.css" rel="stylesheet" media="screen">
	<link href="__PUBLIC__/css/font-awesome.min.css" rel="stylesheet" >
	
	<!--[if IE 7]>
	<link  href="__PUBLIC__/css/font-awesome-ie7.min.css" rel="stylesheet">
	<![endif]-->

	<link href="__PUBLIC__/css/bootstrap-responsive.css" rel="stylesheet">
	<link href="__PUBLIC__/css/test.css" rel="stylesheet">
	<script src="__PUBLIC__/js/jquery.js"></script>
	<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
	<!--[if lt IE 9]>
	<script src="__PUBLIC__/js/html5shiv.js"></script>
	<script src="__PUBLIC__/js/respond.min.js"></script>
	<![endif]-->
</head>
<body>
	<div class="shade"></div>
	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span9 content">

<script type="text/javascript">
	function btn_search() {
		sendForm("form_search", "__SELF__/");
		$("#form_search").submit();
	}

	function key_search() {
		if (event.keyCode == 13) {
			sendForm("form_search", "__SELF__/");
			return false;
		}
	}

	function save() {
		if ($("input:checked[name='user_list[]']").length < 1) {
			alert("请选择用户");
			return false;
		};
		if ($("input:checked[name='role_list[]']").length < 1) {
			alert("请选择权限");
			return false;
		};
		sendForm("form_data", "<?php echo U('set_role');?>");
	}

	function showdata(result) {
		$("input[name='role_list[]']").each(function() {
			$(this).attr("checked", false);
		});
		for (var s in result.data) {
			$("#role_" + result.data[s].role_id).attr("checked", "checked");
		}
	}


	$(document).ready(function() {
		set_return_url();
		$("#emp_all").change(function() {
			//alert($("#emp_all").attr("checked"));
			if ($("#emp_all").attr("checked") == "checked") {
				$("input[name='user_list[]']").each(function() {
					$(this).attr("checked", "checked");
				});
			} else {
				$("input[name='user_list[]']").each(function() {
					$(this).attr("checked", false);
				});
			}
		})
		$(".sub_left_menu  tr").click(function() {
			$(".sub_left_menu  tr").attr("class","");
			$(this).attr("class","active");
			sendAjax("<?php echo U('get_role_list');?>", "id=" + $(this).attr("id"), function(data) {
				showdata(data);
			});
		})
	}); 
</script>
<div class="admin" >
	<form method="post" action="" id="form_search" name="form_search">
		<div class="row-fluid title">
			<span>用户管理</span>
			<div class="input-append right">
				<input type="text"  onkeydown="key_search();" name="keyword">
				<a class="btn" type="button" onclick="btn_search();"> <i class="icon-search"></i>
				</a>
			</div>
		</div>
	</form>
	<div class="row-fluid operate" >
		<div class="right">
			<a onclick="save()" class="btn">保存</a>
		</div>
	</div>
</form>
<!-- 列表显示区域  -->
<form id="form_data" name="form_data"method="post" action="">
	<div class="row-fluid">
		<div class="span8 sub_left_menu">
			<table class="table table-bordered">
				<tr>
					<th style="width:3%;vertical-align: -3px;">
							<input  type="checkbox" id="select_all" value="all" onclick="select_all('emp_id')"/>
					</th>
					<th>
						<nobr>员工编号</nobr>
					</th>
					<th>
						<nobr>姓名</nobr>
					</th>
					<th>
						<nobr>部门</nobr>
					</th>
					<th>
						<nobr>职级</nobr>
					</th>
					<th>
						<nobr>职责</nobr>
					</th>
					<th>
						<nobr>状态</nobr>
					</th>
				</tr>
				<?php if(is_array($user_list)): $i = 0; $__LIST__ = $user_list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$data): $mod = ($i % 2 );++$i;?><tr id="<?php echo ($data["id"]); ?>">
						<td style="text-align: center">
							<div class="chk_wrap">
								<input type="checkbox" name="user_list[]" value="<?php echo ($data["id"]); ?>"></div>
						</td>
						<td>
							<nobr><?php echo ($data["emp_no"]); ?></nobr>
						</td>
						<td>
							<nobr><?php echo ($data["emp_name"]); ?></nobr>
						</td>
						<td>
							<nobr><?php echo ($data["dept_name"]); ?></nobr>
						</td>
						<td>
							<nobr><?php echo ($data["rank_name"]); ?></nobr>
						</td>
						<td>
							<nobr><?php echo ($data["position_name"]); ?></nobr>
						</td>
						<td>
							<nobr><?php echo (status($data["status"])); ?></nobr>
						</td>
					</tr><?php endforeach; endif; else: echo "" ;endif; ?>
			</table>
		</div>
		<div class="span4 last sub_content">
			<input type="hidden" name="id" id="id">
			<input type="hidden" name="pid" id="pid" value="<?php echo ($pid); ?>">
			<input type="hidden" name="ajax" id="ajax" value="1">
			<input type="hidden" name="opmode" id="opmode" value="">
			<table class="table table-bordered">
				<tr>
					<th>&nbsp;</th>
					<th>名称</th>
				</tr>
				<?php if(is_array($role_list)): $i = 0; $__LIST__ = $role_list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$data): $mod = ($i % 2 );++$i;?><tr id="<?php echo ($data["id"]); ?>">
						<td>
							<input type="checkbox" id="role_<?php echo ($data["id"]); ?>" name="role_list[]" value="<?php echo ($data["id"]); ?>"></td>
						<td><?php echo ($data["name"]); ?></td>
					</tr><?php endforeach; endif; else: echo "" ;endif; ?>
			</table>
		</div>
	</div></div>
		</div>
	</div>
	<div class="msg popout">
	</div>
	<!--<iframe src="<?php echo U('/push/client');?>" class="push" id="push"></iframe>-->
	<script src="__PUBLIC__/js/bootstrap.min.js"></script>
	<script src="__PUBLIC__/js/common.js"></script>
	<script src="__PUBLIC__/lib/ligerUI/js/ligerui.min.js" type="text/javascript"></script> 
     <link href="__PUBLIC__/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" /> 
	<script type="text/javascript" src="http://tajs.qq.com/stats?sId=20624928" charset="UTF-8"></script>
</body>
</html>